<template>
  <div id="app">
  <input type="text" v-model="value" @keyup.enter="onEnter" />
      <div ref="parent">
          <div v-for="item of arr" :key="item">{{item}}</div>
      </div>
  </div>
</template>

<script>


export default {
  name: 'App',
  data() {
    return {
      value:0,
      arr:[1,2,3],
      isShow:true
    }
  },
  methods: {
    onEnter(){
      this.arr.push(this.value)//异步，先走下面的输出
      //console.log(this.$refs.parent.children.length)//原来数组的长度

      /* this.$nextTick(()=>{
        //等待DOM异步更新完毕之后，在执行里面的code
        console.log(this.$refs.parent.children.length)
      }); */
      setTimeout(() => {
        console.log(this.$refs.parent.children.length)
      });
    }
  },
}
</script>

<style>
</style>
